<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" version="-//W3C//DTD XHTML 1.1//EN" dir="ltr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>HelloService Example</title>
    <link href="css/samples.css" rel="stylesheet" type="text/css">
    <?php
        require_once("lib/jsonsscli.php");
        ini_set("error_reporting", false);
    ?>
</head>
<body><div id="page-content">

    <h1>HelloService Example</h1>

    <h3>Service exchange log</h3>
    <pre class="console"><?php 

    JSONSSProxy::initLibrary();

    $url = "http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["SCRIPT_NAME"]) . "/hello.php";
    echo "URL = " . $url . "\r\n";

    try { 
        $proxy = JSONSSProxy::fromUrl($url);
        echo "Got proxy object: Proxy.HelloService.serviceUrl = " . $proxy->HelloService->serviceUrl . "\r\n";

        echo "Proxy.HelloService.SayHello() returns: " . $proxy->HelloService->SayHello() . "\r\n";
        echo "Request sent:\r\n";
        echo $proxy->HelloService->lastRequestHeaders . "\r\n";
        echo $proxy->HelloService->lastRequest . "\r\n";
        echo "HTTP status received: " . $proxy->HelloService->lastStatus . "\r\n";
        echo "Response received:\r\n";
        echo $proxy->HelloService->lastResponseHeaders . "\r\n";
        echo $proxy->HelloService->lastResponse . "\r\n";
    } catch (Exception $x) { 
        echo "Ooops! Exception: ". $x->getMessage() . "\r\n"; 
        echo "Request sent:\r\n";
        echo $proxy->HelloService->lastRequestHeaders . "\r\n";
        echo $proxy->HelloService->lastRequest . "\r\n";
        echo "HTTP status received: " . $proxy->HelloService->lastStatus . "\r\n";
        echo "Response received:\r\n";
        echo $proxy->HelloService->lastResponseHeaders . "\r\n";
        echo $proxy->HelloService->lastResponse . "\r\n";
    } 

    JSONSSProxy::shutdownLibrary();

    ?></pre>
</div></body>
</html>
